package com.atguigu.crowd.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 注解方式对springMVC进行扩展配置
 *
 * @author cyb315
 * @create 2021-11-06 22:28
 */
@Configuration
public class CrowdWebMvcConfig implements WebMvcConfigurer {

    /**
     * 注解配置视图控制器
     *
     * @param registry
     */
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        // 1.会员注册功能：浏览器访问的地址路径
        String urlPath = "/auth/member/to/reg/page.html";
        // 会员注册功能：目标视图名称
        String viewName = "member-reg";
        // 添加一个view-controller，跳转到会员注册页面
        registry.addViewController(urlPath).setViewName(viewName);
        // 2.跳转到会员登录页面的view-controller
        registry.addViewController("/auth/member/to/login/page.html").setViewName("member-login");
        // 3.跳转到会员主页面的view-controller
        registry.addViewController("/auth/member/to/center/page").setViewName("member-center");
        // 4.跳转到我的众筹页面
        registry.addViewController("/member/my/crowd").setViewName("member-crowd");
    }
}
